home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / SPEC Libs / TRACS.Lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  10.4 KB  |  299 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:    TRACS.Lib
  5. #
  6. #    Contains:    Library used for logging TRACS data.
  7. #
  8. #    Written by:    JC
  9. #
  10. #    Copyright:    © 1993-1996 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #         <6>     6/18/96    MDF        Added support to TRACS_Output() task in order to track the
  19. #                                    number of failed test cases.
  20. #         <5>     3/11/96    JC        Modified to call BuildSuiteFields regardless if Results Express
  21. #                                    global to set to false if TRACS global is set to true.
  22. #         <4>     2/29/96    JC        Added carriage return after TRACS output checksum.
  23. #         <3>     2/26/96    JC        Minor fix variable name.
  24. #         <2>     2/26/96    JC        Added suite result code comments.
  25. #         <1>     2/23/96    JC        first checked in
  26. #
  27. # ****************************************************************************
  28. #
  29.  
  30. ########################################################################
  31. #                            External libraries 
  32. #=======================================================================
  33. Libraries  'ExceptionHandling.Lib', 'FileToolOperations.Lib';
  34.  
  35. #########################################################################
  36. #                            TRACS_DataCollection()
  37. #========================================================================
  38. # Author:        JC
  39. # Description:    Collects TRACS output data and stores it in a global variable. It will 
  40. #                then call TRACS_Output() for formatting & writing when parameter pDataComplete 
  41. #                is equal to true.
  42. # Parameters:    pData
  43. # Returns:        Nothing
  44. # Examples:        TRACS_DataCollection(pTRACS_Data, pDataComplete := 0)
  45. # Assumptions:    
  46. #
  47. #########################################################################
  48. #========================================================================
  49. # History:
  50. #########################################################################
  51. task TRACS_DataCollection(pTRACS_Data, pDataComplete := 0)
  52. begin    
  53.  
  54.     global gTRACS_OutputData := gTRACS_OutputData + pTRACS_Data;
  55.     
  56.     if (pDataComplete)
  57.         TRACS_Output(gTRACS_OutputData);
  58.  
  59. end;
  60. #########################################################################
  61. #                            TRACS_CreateOutputFile()
  62. #========================================================================
  63. # Author:        JC
  64. # Description:    Checks to see if TRACS output folder/s (pTRACSFileNamePath) exists 
  65. #                if not it will create them (using Filetool on the host). 
  66. #
  67. # Parameters:    pTRACSFileNamePath = folder/file path.
  68. # Returns:        
  69. # Examples:        TRACSFileNamePath := TRACS_CreateOutputFile(pTRACSFileNamePath);
  70. # Assumptions:    
  71. #
  72. #########################################################################
  73. #========================================================================
  74. # History:
  75. #########################################################################
  76. task TRACS_CreateOutputFile(pTRACSFileNamePath)
  77. begin
  78.         
  79.     switch ExistsOrCreate(pTRACSFileNamePath, 0)
  80.     begin
  81.         case 1:
  82.             println "## TRACS output folder existed: {pTRACSFileNamePath}";
  83.         case 2:
  84.             println "## Created TRACS output file: {pTRACSFileNamePath}";
  85.         case 3:
  86.             println "## Created TRACS output folder: {pTRACSFileNamePath}";
  87.         default:
  88.             println "## Fail ({pTRACSFileNamePath}, doesn't exist, couldn't create TRACS output folder)";
  89.     end;
  90.  
  91. end;
  92. #########################################################################
  93. #                            TRACS_CreateFilePath()
  94. #========================================================================
  95. # Author:        JC
  96. # Description:    Creates TRACS folder/file paths. First folder will be 
  97. #                named "TRACSOutput", second folder, within the first one will 
  98. #                be named the suite name. A output file is also generated using 
  99. #                the target name and date/time as the file name.
  100. #
  101. # Parameters:    pSuiteName = suite name.
  102. #                pTargetName = target name.
  103. # Returns:        TRACS File Name/Path
  104. # Examples:        TRACSFileNamePath := TRACS_CreateOutputFile(SuiteName, TargetName);
  105. # Assumptions:    
  106. #
  107. #########################################################################
  108. #========================================================================
  109. # History:
  110. #########################################################################
  111. task TRACS_CreateFilePath(pSuiteName, pTargetName)
  112. begin
  113.     HostBootVol := NameOfBootVolume(0);
  114.     
  115.     TRACSFileNamePath := "{HostBootVol}:TRACSOutput:";
  116.     
  117.     TRACS_CreateOutputFile(TRACSFileNamePath);
  118.             
  119.     TRACSFileNamePath := "{HostBootVol}:TRACSOutput:{pSuiteName}:";
  120.     
  121.     TRACS_CreateOutputFile(TRACSFileNamePath);
  122.     
  123.     Try
  124.     begin
  125.         match[time d:?day m:?month y:?year h:?hour s:?seconds];
  126.         timestamp := "{month}{day}{hour}{seconds}";
  127.     end;
  128.     catch theError
  129.         ExceptionDispatcher(theError);
  130.         
  131.     TRACSFileNamePath := "{HostBootVol}:TRACSOutput:{pSuiteName}:{pTargetName}{timestamp}";
  132.  
  133.     TRACS_CreateOutputFile(TRACSFileNamePath);
  134.     
  135.     return(TRACSFileNamePath);
  136. end;
  137. #########################################################################
  138. #                            TRACS_Output()
  139. #========================================================================
  140. # Author:        JC
  141. # Description:    This task will order the TRACS data correctly and call FileTool to
  142. #                write to the file.
  143. # Parameters:    pTRACS_OutputData = a list of TRACS data.
  144. # Returns:        Nothing
  145. # Examples:        TRACS_Output(gTRACS_OutputData);
  146. # Assumptions:    
  147. #
  148. #########################################################################
  149. #========================================================================
  150. # History:
  151. #
  152. #     2/26/96    JC    Added suite result code comments.
  153. # MDF    06/18/96    Added support for tracking number of failed test cases.
  154. #########################################################################
  155. task TRACS_Output(pTRACS_OutputData)
  156. begin
  157.     println "";
  158.     
  159.     SuiteName := assoc("SuiteName", pTRACS_OutputData);
  160.     TargetName := assoc("TargetName", pTRACS_OutputData);
  161.  
  162.     TRACSFileNamePath := TRACS_CreateFilePath(SuiteName, TargetName);
  163.  
  164.     Comment_Text := "";
  165.     numTimes := Card(pTRACS_OutputData);
  166.  
  167.     for i := 1 to numTimes            # For each element of the pTRACS_Data
  168.     begin
  169.         Comment_Text := Comment_Text + pTRACS_OutputData[i][1] + ":" + ToText(pTRACS_OutputData[i][2]) + " ";
  170.     end;
  171.     
  172.     SuiteCompletionDate := assoc("Suite End Date", pTRACS_OutputData);
  173.  
  174.     SuiteResultCode := assoc("Suite Completion Code", pTRACS_OutputData);
  175.  
  176.     switch SuiteResultCode
  177.     begin
  178.         case -1:                            ## -1 (SPEC S&L) = Skipped
  179.             SuiteResultCode := "5";            ## 5 (TRACS) = Not Executed
  180.         case -2:                            ## -2 (SPEC S&L) = System Failure
  181.             SuiteResultCode := "2";            ## 2 (TRACS) = Fail
  182.         case -3:                            ## -3 (SPEC S&L) = Not Validated
  183.             SuiteResultCode := "5";            ## 5 (TRACS) = Not Executed
  184.         case  0:                            ## 0 (SPEC S&L) = Incomplete
  185.             SuiteResultCode := "2";            ## 2 (TRACS) = Fail
  186.         case  1:                            ## 1 (SPEC S&L) = OK
  187.             SuiteResultCode := "1";            ## 1 (TRACS) = Pass
  188.         default:
  189.             SuiteResultCode := "7";            ## 7 (TRACS) = Invalid
  190.     end;        
  191.     
  192.     NotExecuted := assoc("TCS Not Avail", pTRACS_OutputData);        
  193.     SuiteTCSPassed := assoc("TCS Passed", pTRACS_OutputData);
  194.     Failed := assoc("TCS Failed",pTRACS_OutputData);
  195.     ExpFailure := assoc("TCS Exp Count", pTRACS_OutputData);
  196.     Blocked := "0";
  197.     Canceled := "0";
  198.     Invalid := "0"; 
  199.     
  200.     unformattedData := {SuiteName, 
  201.                         SuiteCompletionDate, 
  202.                         SuiteResultCode, 
  203.                         NumericVal, 
  204.                         ErrorMsg, 
  205.                         RadarNo, 
  206.                         NotExecuted, 
  207.                         SuiteTCSPassed, 
  208.                         Failed, 
  209.                         ExpFailure, 
  210.                         Blocked, 
  211.                         Canceled, 
  212.                         Invalid, 
  213.                         Comment_Text
  214.                         };
  215.     
  216.     formattedData := TRACSFormatData(unformattedData);
  217.     
  218.     WriteToFileToolHost(TRACSFileNamePath, formattedData );
  219.  
  220.     QuitFileTool(0);
  221. end;
  222.  
  223. #########################################################################
  224. #                            ToText()
  225. #========================================================================
  226. # Author:        JC
  227. # Description:    a utility task to convert integer data to strings.
  228. # Parameters:    pData
  229. # Returns:        Nothing
  230. # Examples:        
  231. # Assumptions:    
  232. #
  233. #########################################################################
  234. #========================================================================
  235. # History:
  236. #########################################################################
  237. task ToText( pData )
  238. begin
  239.     if( typeOf( pData ) = 'string' ) return pData;
  240.     if( typeOf( pData ) = 'integer' ) return NumToStr( pData );
  241.     return undefined; # else
  242. end;
  243. #########################################################################
  244. #                            WriteToFileToolHost()
  245. #========================================================================
  246. # Author:        JC
  247. # Description:    a utility task used by WriteToFile.
  248. # Parameters:    pTRACSFileNamePath = file name path
  249. #                pformattedData = formatted data (list)
  250. # Returns:        Nothing
  251. # Examples:        
  252. # Assumptions:    
  253. #
  254. #########################################################################
  255. #========================================================================
  256. # History:
  257. #########################################################################
  258. task WriteToFileToolHost( pTRACSFileNamePath, pformattedData )
  259. begin
  260.     FileToolReturnVal := _FileTool('Write', {pTRACSFileNamePath, 0, pformattedData},0);
  261.     return FileToolReturnVal;
  262. end;
  263. #########################################################################
  264. #                            TRACSFormatData()
  265. #========================================================================
  266. # Author:        JC
  267. # Description:    This task will receive a list of ordered TRACS column data, 
  268. #                if the list element is undefined it will insert a blank tab in
  269. #                its place so TRACS knows there is no data for that column.
  270. # Parameters:    pUnformattedData = list of ordered TRACS column data.
  271. # Returns:        formatted String
  272. # Examples:        formattedData := TRACSFormatData(unformattedData);
  273. # Assumptions:    list of ordered TRACS column data.
  274. #
  275. #########################################################################
  276. #========================================================================
  277. # History:
  278. # JC    2/29/96    Added ∂n (carriage return) after numOfRows variable.
  279. #########################################################################
  280. task TRACSFormatData(pUnformattedData := {})
  281. begin
  282.     Tab := "∂t";
  283.     formattedString := "";
  284.     numOfRows := 1;
  285.     
  286.     numTimes := Card(pUnformattedData);
  287.  
  288.     for i := 1 to numTimes            # For each element of the pTRACS_OutputData
  289.     begin
  290.         if (IsUndefined(pUnformattedData[i]))
  291.             pUnformattedData[i] := "";
  292.         
  293.         formattedString := formattedString + ToText(pUnformattedData[i]) + Tab;
  294.     end;
  295.     
  296.     formattedString := formattedString + "∂n{numOfRows}∂n";
  297.     
  298.     return(formattedString);
  299. end;